// PluginICProcStepsApp.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include <stdlib.h>
#include <string>
#include <iostream>
#include "PluginICProcSteps.h"

#include "MxPluginLibs.h"
#include "IPluginXmlDoc.h"

int main(int argc, char* argv[])
{

	std::cout << "PluginICProcStepsApp v1.0.0.2 - program starts" << std::endl << std::endl;

	MxPluginLibs plugins;
	std::string  errorMsg("Error: not set");
	if (MxPluginLibs::InitPlugins(&plugins, &errorMsg) == false)
		std::cout << errorMsg;
	else
	{
		PluginICProcSteps lib;
		MxPluginLib *PluginICProcSteps = '\0';
		if ((PluginICProcSteps = plugins.GetPlugin(lib.GetLibID())) == '\0')	//same as lib.GetLibID() - see PluginXml, VS_VERSION_INFO, Internal name 
			std::cout << "Error: MxPlugin LibID=[" << lib.GetLibID() << "] not found" << std::endl;
		else
		{
			MxPluginLib *pluginXml = '\0';
			if ((pluginXml = plugins.GetPlugin("DEE06017-72D8-45DF-AB37-5012019751D5")) == '\0')	//this is not IPluginXmlLibIID::GUID() it is same as lib.GetLibID() - see PluginXml, VS_VERSION_INFO, Internal name 
				std::cout << "Error: MxPlugin LibID=[DEE06017-72D8-45DF-AB37-5012019751D5] not found" << std::endl;
			else
			{
				std::cout << PluginICProcSteps->GetLibDetails() << std::endl << std::endl;

				IPluginICProcSteps *expt = '\0';
				if ((expt =  static_cast<IPluginICProcSteps *>(PluginICProcSteps->CreateClassInstance(IPluginICProcStepsIID::GUID()))) == '\0')
					std::cout << "Error: IPluginICProcSteps interface=[" << IPluginICProcStepsIID::GUID() << "] not found" << std::endl;
				else
				{
					IPluginXmlDoc *doc = '\0';
					if ((doc =  static_cast<IPluginXmlDoc *>(pluginXml->CreateClassInstance(IPluginXmlDocIID::GUID()))) == '\0')
						std::cout << "Error: IPluginXmlDoc interface=[" << IPluginXmlDocIID::GUID() << "] not found" << std::endl;
					else
					{
						std::cout << "Success: expt->GetLibApiDetails() returns: " << expt->GetLibApiDetails() << std::endl;
						std::cout << "Success: doc->GetElementTextIllegalChars() returns: " << doc->GetElementTextIllegalChars() << std::endl;
						doc->DestroyPtr();
					}
					expt->DestroyPtr();
				}
			}
		}
	}

	std::cout << "PluginICProcStepsApp - program end" << std::endl;

	return 0;
}

